<template>
  <div class="item" @click="itemClick()">
    <div v-if="!isActive">
      <slot name="tab-img"></slot>
    </div>
    <div v-else>
      <slot name="tab-img-active"></slot>
    </div>
    <div :style="styleActive">
      <slot name="tab-text"></slot>
    </div>
    <!-- <div :class="{ active: isActive }">
      <slot name="tab-text"></slot>
    </div> -->
  </div>
</template>

<script>
export default {
  props: {
    path: String,
    activeColor: {
      type: String,
      default: "red",
    },
  },
  data() {
    return {
      //   isActive: false,
    };
  },
  created() {
    console.log(this.styleActive);
  },
  computed: {
    isActive() {
      return this.$route.path.indexOf(this.path) !== -1;
    },
    styleActive() {
      return this.isActive ? { color: this.activeColor } : {};
    },
  },
  methods: {
    itemClick() {
      console.log(this.path);
      this.$router.push(this.path);
    },
  },
};
</script>

<style lang='less'  scoped>
.item {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  img {
    display: block;
    width: 24px;
    height: 24px;
  }
}
</style>